package com.tiancheng.trade.settlement.service.settlement;


import com.tiancheng.trade.commom.core.data.PageInfo;
import com.tiancheng.trade.settlement.model.settlement.SettlementRule;
import com.tiancheng.trade.settlement.vo.settlement.api.GetSettlementRuleVO;
import com.tiancheng.trade.settlement.vo.settlement.api.OpenAddRuleVO;
import com.tiancheng.trade.settlement.vo.settlement.api.OpenDeleteRuleVO;
import com.tiancheng.trade.settlement.vo.settlement.api.SettlementRuleVO;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public interface ISettlementRuleService {

    /**
     * 根据ID查询
     *
     * @param id
     * @return
     */
    SettlementRule findById(Long id);

    /**
     * 查询清分规则列表信息
     *
     * @param settlementRuleVO
     * @return
     */
    PageInfo<SettlementRule> getSettlementRule(GetSettlementRuleVO settlementRuleVO);

    /**
     * 查询清分规则信息
     *
     * @param settlementRuleVO
     * @return
     */
    List<SettlementRule> getSettlementRuleList(GetSettlementRuleVO settlementRuleVO);

    /**
     * 按照生效时间和优先级查询是否有多少有效规则
     *
     * @param settlementRule
     * @return
     */
    List<SettlementRule> findSettlementRuleByLevel(SettlementRule settlementRule);

    /**
     * 按条件查询单个清分规则
     *
     * @param settlementRuleVO
     * @return
     */
    SettlementRule getSettlementByParam(GetSettlementRuleVO settlementRuleVO);

    /**
     * 商品编码，优先级，生效时间大于当前时间并且规则失效时间小于当前时间
     * 按优先级排序
     *
     * @param settlementRuleVO
     * @return
     */
    SettlementRule getSettlementByCodeLevel(SettlementRuleVO settlementRuleVO);

    /**
     * 查询当前日期未生效的清分规则信息
     * 为自动生效做准备
     *
     * @param settlementRuleVO
     * @return
     */
    List<SettlementRule> getIneffectiveRuleList(GetSettlementRuleVO settlementRuleVO);

    /**
     * 查询当前日期生效的清分规则信息
     * 为自动失效做准备
     *
     * @param settlementRuleVO EFFECTIVE
     * @return
     */
    List<SettlementRule> getEffectiveRuleList(GetSettlementRuleVO settlementRuleVO);

    /**
     * 查询清分规则信息-按商户编号批量查询
     *
     * @param listStr
     * @return
     */
    List<SettlementRule> getSettlementRuleByMerCode(List<String> listStr);

    /**
     * 查询清分规则信息-按商户编号,产品编号批量查询
     *
     * @param merStr
     * @param proStr
     * @return
     */
    List<SettlementRule> getSettlementRuleByMerProCode(List<String> merStr, List<String> proStr, String date);

    /**
     * 新增清分规则
     *
     * @param settlement
     * @return
     */
    int add(SettlementRule settlement);

    /**
     * 修改清分规则状态
     *
     * @param settlement
     * @return
     */
    int update(SettlementRule settlement);

    /**
     * 修改商户名称时同时修改清分规则的商户名称
     *
     * @param settlement
     * @return
     */
    int updateMerchantName(SettlementRule settlement);

    /***
     * 作废清分规则
     * @param ruleId
     * @return
     */
    int updateCancel(Long ruleId);

    /**
     * 定时生效
     *
     * @return
     */
    int autoEffective();

    /**
     * 定时失效
     *
     * @return
     */
    int autoExpired();

    /**
     * 清分规则导出
     *
     * @param settlementRuleVO
     * @param request
     * @param response
     * @throws IOException
     */
    void export(GetSettlementRuleVO settlementRuleVO, HttpServletRequest request, HttpServletResponse response) throws IOException;

    /**
     * 根据交易中台商品编码批量查询清分规则
     *
     * @param productCodes
     * @return
     */
    List<SettlementRule> getRulesByProductCodes(List<String> productCodes);

    /**
     * 添加清分规则
     * @param openAddRuleVO
     * @return
     */
    String addRule(OpenAddRuleVO openAddRuleVO);

    /**
     * 开放接口-删除清分规则
     * @param openDeleteRuleVO
     */
    void openDeleteRule(OpenDeleteRuleVO openDeleteRuleVO);
}
